﻿using System;
using System.Collections.Generic;
using WEB.Core.Controls;
using Ext.Net;
using WEB.Core.Util;
using log4net;
using WEB.BLL.Services;
using WEB.BLL.Entities;
using WEB.BLL;

namespace WEB.APP.Modules.List
{
    public partial class ListBreifCV : BasePage
    {
        public ListBreifCV() : base(SCREENS.LISTBREIFCV, false)
        {
        }

        protected override void Page_Load(object sender, EventArgs e)
        {
            AddListControlAdd(tbsAdd);
            hdScreenDetailID.Value = SCREENS.BREIFCVDETAIL;
            base.Page_Load(sender, e);
            mnEdit.Text = "View";
        }

        protected void storeMain_OnRefreshData(object sender, StoreRefreshDataEventArgs e)
        {
            try
            {
                CvEntity CvE = new CvEntity()
                {
                    Keyword = hfKeyword.Text.Trim(),
                    Start = Util.Obj2Int(e.Parameters["start"])
                };
                CvE.EndNum = Util.Obj2Int(e.Parameters["limit"]) + CvE.Start;
                IList<CvEntity> lstRole = CvService.GetInstance().Find(CvE);
                if (null == lstRole)
                    return;
                storeMain.DataSource = lstRole;
                e.Total = CvE.TotalRow;
                storeMain.DataBind();
            }
            catch (Exception ex)
            {
                Notification(ex);
            }
        }
        [DirectMethod]
        public void Delete(int Id)
        {
            try
            {
                if (Id > 0)
                {
                    ExpertiseCVEntity ExpertiseCVE = new ExpertiseCVEntity() { StudentId = Convert.ToDecimal(Id) };
                    ExpertiseCVService.GetInstance().DeleteByStudentId(ExpertiseCVE);

                    CvEntity CvE = new CvEntity { StudentId = ExpertiseCVE.StudentId };
                    CvService.GetInstance().Delete(CvE);
                    this.storeMain.DataBind();
                }
            }
            catch (Exception ex)
            {
                Notification(ex);
            }
        }
    }
}
